// mycomponent/custom-tabbar/index.js
const tabbarList = [
  {name: 'home', text: '首页', img: '/image/icon/home.png', activeImg: '/image/icon/home-active.png'},
  {name: 'category', text: '分类', img: '/image/icon/category.png', activeImg: '/image/icon/category-active.png'},
  {name: 'store', text: '店铺', img: '/image/icon/store.png', activeImg: '/image/icon/store-active.png'},
  {name: 'cart', text: '购物车', img: '/image/icon/cart.png', activeImg: '/image/icon/cart-active.png'},
  {name: 'my', text: '我的', img: '/image/icon/my.png', activeImg: '/image/icon/my-active.png'}
]
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    active: {
      type: String,
      value: ''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    tabbarList,
    iconWidth: '30px',
    iconHeight: '24px'
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * tabbar切换
     * @param {Object} e 
     */
    tabbarChange: function(e) {
      const { detail } = e
      const { active } = this.data
      if (detail != active) {
        if (detail == 'home') {
          wx.redirectTo({
            url: '/packageK/index/index',
          })
        } else if (detail == 'category') {
          wx.redirectTo({
            url: '/packageK/category/category',
          })
        } else if (detail == 'store') {
          wx.redirectTo({
            url: '/packageC/o2o/o2oHome/o2oHome',
          })
        } else if (detail == 'cart') {
          wx.redirectTo({
            url: '/packageG/pages/buy/cart_v2/cart_v2',
          })
        } else if (detail == 'my') {
          wx.redirectTo({
            url: '/packageK/my/my',
          })
        }
      }
    }
  }
})